package com.lansi.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.lansi.bean.Key;
import com.lansi.mapper.KeyMapper;


@Service
public class KeyService  implements IKeyService{
	@Resource
	private KeyMapper keyMapper;
	@Override
	public void register(Key key) {		
			keyMapper.insertKey(key);
			
	}

	//验证邮箱是否存在
	@Override
	public boolean checkEmail(String email) {
		Key email1 = keyMapper.selectByEmail(email);
		System.out.println(email1);
		
		if(email1!=null) {
			return true;//存在
		}else {
			return false;//不存在
		}
	
	}

	//根据id删除信息-可以批量删除
	@Override
	public void delKey(Integer[] ids) {
		keyMapper.deleteKey(ids);
		
	}

	//单个删除用户，根据id
	@Override
	public void delById(Integer id) {
		keyMapper.deleteById(id);
		
	}


	@Override
	public boolean checkRegcode(String regcode) {
		Key regcode1 = keyMapper.selectByRegcode(regcode);
		
		if(regcode1!=null) {
			return true;//存在
		}else {
			return false;//不存在
		}	
	}

	@Override
	public Key getEmail(String email) {
		
		return keyMapper.selectByEmail(email);
	}
	//查询数据库注册码数量
	@Override
	public Integer getKeycount() {
		
		return keyMapper.selectKeycount();
	}

	@Override
	public List<Key> getKey(Integer offset,Integer count) {
		// TODO Auto-generated method stub
		return keyMapper.selectKey(offset, count);
	}
	
}
